from socket import *
print("Your computer: ",gethostname())
me=socket(AF_INET,SOCK_STREAM)
me.bind((gethostname(),12345))
me.listen(2)
ag,addr=me.accept()

cnt=0
while True:
    k=5
    d=5
    mhp=3
    yhp=3
    print("your point(s):",cnt)
    while mhp>0 and yhp>0:
        print(f"You have {k} kill card(s),and {d} dodge card(s)")
        print(f"You have {mhp} hp,your enemy has {yhp} hp.")
        x=input("input k to kill,d to dodge,and anything else to pass:")
        if x=='k' and k==0 :
            print("You have no kill card,you pass this turn.")
            x='pass'
        if x=='d' and d==0 :
            print("You have no dodge card,you pass this turn.")
            x='pass'
        if x!='k' and x!='d' :print("You pass this turn.")
        if x=='k':k-=1
        if x=='d':d-=1
        y=ag.recv(10).decode("ASCII")
        ag.send(x.encode("ASCII"))
        if x=='k':yhp-=1
        if y=='k':mhp-=1
        if x=='d' and y=='k':mhp+=1
        if y=='d' and x=='k':yhp+=1
    if mhp==0 and yhp==0:
        print("draw")
    elif mhp==0:
        print("lose")
        cnt-=1
    else:
        print("win")
        cnt+=1
